package cn.mn.ac.rocketmq.config;

import cn.mn.ac.rocketmq.handler.SendCallbackHandler;
import cn.mn.ac.rocketmq.register.ConsumerAutoRegister;
import cn.mn.ac.rocketmq.resolver.PropertyResolver;
import cn.mn.ac.rocketmq.env.EnvironmentVirtual;
import cn.mn.ac.rocketmq.props.RocketProperties;
import com.aliyun.openservices.ons.api.MessageListener;
import com.aliyun.openservices.ons.api.ONSFactory;
import com.aliyun.openservices.ons.api.SendCallback;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * @author: zhuCan
 * @date: 2020/1/10 17:40
 * @description:
 */
@Configuration
@ConditionalOnProperty(prefix = "rocket", value = "enable")
@ConditionalOnClass({MessageListener.class, ONSFactory.class})
@Import({ConsumerAutoRegister.class})
public class RocketAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean(ConsumerAutoRegister.class)
    public ConsumerAutoRegister consumerAutoRegister() {
        return new ConsumerAutoRegister();
    }

    @Bean
    @ConditionalOnMissingBean(SendCallback.class)
    public SendCallback sendCallback() {
        return new SendCallbackHandler();
    }

}
